// var p1 = new Promise((resolve, reject) => {
//   //   resolve('success')
//   //   reject('error')
//   setTimeout(() => {
//     resolve('success')
//   }, 3000)
// }).then(
//   (res) => console.log(res),
//   (err) => console.log('error')
// )

// var p1 = new Promise((resolve, reject) => {
//   resolve(100)
// })
//   .then((res) => 2 * res)
//   .then((res) => console.log(res)) // 200

// var p2 = new Promise((resolve, reject) => {
//   resolve(100)
// })
//   .then((res) => new Promise((resolve, reject) => reject('error')))
//   .then(
//     (res) => console.log(res),
//     (reason) => console.log(reason)
//   ) // 200
// console.log('done')
//   执行顺序

let p1 = new Promise((resolve, reject) => {
  resolve('success')
  reject('fail')
})
console.log('p1', p1)